package pri.hillchen.std.concurrent.chapter5;

import java.util.Collection;

/**
 * @author:hillchen
 * @DESCRIPTION:
 * @Date: Created in 10:59 2018/2/7 0007.
 */
public abstract class RemoveLastElementRunable<E> extends Thread {
    private Collection<E> collection;

    public RemoveLastElementRunable(Collection<E> collection) {
        this.collection = collection;
    }

    @Override
    public void run() {
        while(collection.size() > 0){
            removeElement(collection,collection.size() -1);
            try {
                Thread.sleep(10);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

    }
    abstract void removeElement(Collection<E> collection,int index);
}
